<template>
  <div class="cityAlarmTable-root">
    <formTitleVue
      title="地市报警预警分布"
      :selectOptions="selectOptions"
    />
    <el-table
      :data="tableData"
      class="table"
      height="24vh"
      border
      style="width: 100%">
      <el-table-column
        prop="city"
        label="地区">
        <template slot="header" slot-scope="scope">
          <span style="padding-left:20px">地市</span>
        </template>
        <template slot-scope="scope">
          <span style="padding-left:20px">{{scope.row.city}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="yjNum"
        label="预警数量">
      </el-table-column>
      <el-table-column
        prop="bjNum"
        label="报警数量">
      </el-table-column>
    </el-table>
    <!-- <v-table
      :table-columns="tableColumns"
      :table-data="tableData"
      :loading="loading"
      :is-index="true"
      title=""
      maxHeight="30vh"
      ref="table"
    >
    </v-table> -->
  </div>
</template>

<script>
import VTable from "@/components/VTable/index";
import formTitleVue from "@/components/FormTitle/formTitle.vue";
import { time_select_optios } from '@/utils/global.js';
import { areaAlarmWarnList } from '@/api/alarm/statistics'

export default {
  name: "cityAlarmTable",
  components: {
    VTable,
    formTitleVue,
  },
  data() {
    return {
      tableData: [],
      selectOptions: [
        {
          selectValue: "近一月",
          options:[
            { label: "近一月", value: "近一月" },
            { label: "近半年", value: "近半年" },
            { label: "近一年", value: "近一年" },
          ],
          changeFn: this.selectChange2,
        }
      ],
      tableData: [],
      loading: false,
      searChForm: {
        startTime: '',
        endTime: '',
      },
    };
  },
  methods: {
    selectChange2(item){
      this.searChForm.startTime = time_select_optios[item].startTime
      this.searChForm.endTime = time_select_optios[item].endTime
      this.getData()
    },
    init(){
      this.searChForm.startTime = time_select_optios[this.selectOptions[0].selectValue].startTime
      this.searChForm.endTime = time_select_optios[this.selectOptions[0].selectValue].endTime
      this.getData()
    },
    getData() {
      let params ={
        startTime:this.searChForm.startTime+" 00:00:00",
        endTime:this.searChForm.endTime+" 23:59:59",
        areaCode:this.$store.state.account.user.deptIds,
        // 默认市，查询区
        placeType: this.$commonJs.getPlaceType(this.$store.state.account.user.deptIds)
      }
      areaAlarmWarnList(params).then(res=>{
          if(res.code==200){
            this.tableData = res.data
          }
      })
      // ============================
      // console.log(this.searChForm)
      // this.tableData = [
      //   {
      //     month: "2023-09",
      //     city: "广州市",
      //     yjnum: "20",
      //     bjnum: "35"
      //   },
      //   {
      //     month: "2023-09",
      //     city: "深圳市",
      //     yjnum: "22",
      //     bjnum: "41"
      //   },
      //   {
      //     month: "2023-09",
      //     city: "珠海市",
      //     yjnum: "20",
      //     bjnum: "36"
      //   },
      //   {
      //     month: "2023-09",
      //     city: "汕头市",
      //     yjnum: "19",
      //     bjnum: "40"
      //   },
      // ];
    },
  },
  mounted() {
    this.init()
  },
};
</script>

<style lang="scss" scoped>
.cityAlarmTable-root {
  ::v-deep .formTitle-root .form-title-p{
    font-family: SourceHanSansCN-Bold;
    font-size: 16px;
    color: #333333;
    font-weight: 600;
  }
  ::v-deep .el-table thead tr th.is-leaf{
    border: 0px solid #EBEEF5;
    border-right: none;
    background: #EDF3FE !important;
    color: #4A98F8;
  }
  ::v-deep .el-table {
      // 去掉table的border start----------------------------
      border: 0;
      th,tr,td{ border: 0; }
      &::before { height: 0px;}
      &::after {  width: 0;}
      .el-table__fixed:before { height: 0; }
    // 去掉table的border end----------------------------
  }
  //整个table的背景颜色
  ::v-deep .el-table, .el-table__expanded-cell {
    background-color: transparent;
    // color: white;
  }
  //表格整行的颜色
  ::v-deep .el-table tr {
    background-color: transparent!important;
    font-size: 18px;
  }
  ::v-deep .el-table tbody tr:hover>td {
    // background-color: rgba($color: #03487B, $alpha:0.5) !important;
  }
  ::v-deep .el-table-enable-row-transition .el-table__body td, .el-table .cell{
    background-color: transparent;
  }
  ::v-deep .el-table .el-table__cell{
    padding: 8px 0;;
  }
  ::v-deep .el-select > .el-input{
    height: 100%;
  }
  ::v-deep .el-input__suffix{
    top: 4px;
  }
  ::v-deep .el-input__icon{
    line-height: 100%;
    font-size: 0.73vw;
    width: auto;
    top: -6px;
  }
}
</style>
